package pers.qianyu.diytomcat;

import pers.qianyu.diytomcat.classloader.*;

import java.lang.reflect.*;

/**
 * @author mizzle rain
 * @date 2021-01-06 16:37
 */
public class Bootstrap {
    public static void main(String[] args) {
        try {
            CommonClassLoader classLoader = new CommonClassLoader();
            Thread.currentThread().setContextClassLoader(classLoader);
            String serverClassName = "pers.qianyu.diytomcat.catalina.Server";
            Class<?> clazz = classLoader.loadClass(serverClassName);
            Object instance = clazz.newInstance();
            Method method = clazz.getMethod("start");
            method.invoke(instance);
            //System.out.println(clazz.getClassLoader());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
